import unittest
import time
from HTMLTestRunner import HTMLTestRunner
from config.setting import *

def creattest():
    test_dir='./testcase'
    discover=unittest.defaultTestLoader.discover(test_dir,pattern='*_test.py',top_level_dir=None)
    return discover

if __name__=='__main__':
    now=time.strftime('%Y-%m-%d %H_%M_%S')
    now_title=time.strftime('%Y-%m-%d %H:%M')
    filename='{0}{1}{2}'.format(report_path,now,'result.html')
    fp=open(filename,'wb')
    runner=HTMLTestRunner(stream=fp,title='{0}商品反馈接口自动化测试报告'.format(now_title),description='测试环境')
    creatsuite=creattest()
    runner.run(creatsuite)
    fp.close()